package com.moli.lumpSugar.user.dao;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.moli.lumpSugar.common.cache.user.UserCache;
import com.moli.lumpSugar.user.domain.entity.Role;
import com.moli.lumpSugar.user.domain.enums.RoleEnum;
import com.moli.lumpSugar.user.mapper.RoleMapper;
import com.moli.lumpSugar.user.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author zhangjt
 * @since 2024-10-27
 */
@Service
public class RoleDao extends ServiceImpl<RoleMapper, Role> implements IRoleService {
    @Autowired
    private UserCache userCache;

    @Override
    public boolean hasPower(Long uid, RoleEnum admin) {
        Set<Long> roleSet = userCache.getRoleSet(uid);
        if (roleSet.contains(admin.getId())) {
            return true;
        }
        return false;
    }
}
